$(document).ready(function(){
	
    //validate cac form
    $('.validate-form').validate();
    $(".validate-form-login").validate();
    
    //////////////////////////////////////////////
    //CHECK ALL
    //check all in table 
    $('.check-all').click(function(){
        $checkAll = $(this).attr('checked');
        $('.sub-check').each(function(){
            $subCheck = $(this).attr('checked');
            if($checkAll !=$subCheck ) $(this).click();    
        }); 
    });
    
    //
    //check trong Exame table
    $('.check-all-choose').click(function(){
        $checkAll = $(this).attr('checked');
        $('.sub-check-choose').each(function(){
            $subCheck = $(this).attr('checked');
            if($checkAll !=$subCheck ) $(this).click();    
        }); 
    });
    
    //HOVER MENU
//    $('.menu-item a').hover(function(){
//    	$(this).children('ul').slideDown(400);
//    	$('.menu-item-sub').slideDown(400);
    	
//    },function(){
//    	$('.menu-item-sub').slideUp();
//    });
    
    //date picker
    jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "" ] );
    $('#txtDateExpect').datepicker(jQuery.datepicker.regional[ "vi" ]);
//    $('#txtDateEndD').datepicker($.datepicker.regional[ "vi" ]);
//    $('#birthday').datepicker($.datepicker.regional[ "vi" ]); //user controller
//    
//   
    //SUP MENU IN BACKEND
    $('.selectSupMenu').change(function(){        
       $action = $(this).children('option:selected').attr('value');
       window.location.href = baseUrl($action);        
    });     
    
    //
    //COMMENT
    //show 
    $('.lnkComment').click(function(){
        $( "#dialog-comment" ).dialog( "open");   
    });
    $("#dialog-comment").dialog({
		autoOpen: false,
		height: 400,
		width: 430,
		modal: true,           
		
		close: function() {
			allFields.val( "" ).removeClass( "ui-state-error" );
		}
    });
    
    //LOGIN
    $url = window.location.href.split("/");
    if(($url[$url.length-1]=="index" && $url[$url.length-2]=="login")
    	|| ($url[$url.length-1]=="" && $url[$url.length-2]=="login")
    	|| ($url[$url.length-1]=="login" && $url[$url.length-2]!="login")){
	    $("#dialog-loginForm").dialog({
			autoOpen: true,
			height: 180,
			width: 200,
			modal: true,           
			
			close: function() {
				allFields.val( "" ).removeClass( "ui-state-error" );
			}
	    });
    }
    
    //RANDDOM POST 
    $('#randPost').cycle({ 
        fx: 'scrollDown',
        speed: 2500
    });
   
    //
    // === IMAGES SLIDER
    $("#slider").easySlider({
		auto: true, 
		continuous: true,
		speed: 5000
	});
    
});
